import querystring from 'querystring';
import { systemConfig } from '@/util/systemConfig'; 
const query = querystring.parse(global.location.search.substring(1));
console.log(systemConfig, 'systemConfig');

// export const LOCAL_HTTP_SERVER_PORT = systemConfig.simulationService?.port || 25502;
export const LOCAL_SERVER_HOST = `http://localhost:${systemConfig.simulationService?.port?.http || '25502'}/`;
export const LOCAL_SOCKET_SERVER_HOST = `ws://localhost:${systemConfig.simulationService?.port?.http || '25502'}/`;
export const MODEL_SERVER_URL = `http://localhost:${query["NODE_PORT"] || process.env.VUE_APP_NODE_PORT || systemConfig.nodeService?.port || 8237}/`;
export const SIM_BACKEND_PACKAGE_NAME = 'SimService-0.0.1.jar';

export const Metaclasses = {
  SimulationConfig: "Customization::SimulationConfig",
  TimeSeriesChart: "Customization::TimeSeriesChart",
};

export enum PropertyKey {
  SelectPropertiesConfigRepresents = "SelectPropertiesConfig-represents",
  SimulationConfig_autoStart = "SimulationConfig-autoStart",
  SimulationConfig_silent = "SimulationConfig-silent",
  SimulationConfig_autostartActiveObjects = "SimulationConfig-autostartActiveObjects",
  SimulationConfig_animationSpeed = "SimulationConfig-animationSpeed",
  SimulationConfig_executionTarget = "SimulationConfig-executionTarget",
  DiagramMap_displayedAttributes="DiagramMap-displayedAttributes",
  DiagramMap_scope = "DiagramMap-scope",
  DiagramMap_elementTypes = "DiagramMap-elementTypes",
  DiagramMap_contextElement="DiagramMap-contextElement",
  DiagramMap_depth = "DiagramMap-depth",
  Clause_test = "Clause-test",
  Clause_body = "Clause-body",
  Comment_body = "Comment-body",
  Classifier_useCase = 'Classifier-useCase',
  Enumeration_ownedLiteral = 'Enumeration-ownedLiteral',
  Element_image="Element-image",
  Stereotype_icon="Stereotype-icon",
  Connector_kind = "Connector-kind",
  NamedElement_visibility = "NamedElement-visibility",
  Property_aggregation="Property-aggregation",
  CallAction_result = "CallAction-result",
  CallOperationAction_target="CallOperationAction-target",
  CreateObjectAction_result="CreateObjectAction-result",
  StartObjectBehaviorAction_object="StartObjectBehaviorAction-object",
  StructuralFeatureAction_object="StructuralFeatureAction-object",
  ReadStructuralFeatureAction_result="ReadStructuralFeatureAction-result",
  ReadExtentAction_result="ReadExtentAction-result",
  AcceptEventAction_result='AcceptEventAction-result',
  UseCase_extensionPoint='UseCase-extensionPoint',
  Customization_AttachedFile_file = 'Customization::AttachedFile-file',
  Customization_AttachedFile_attachedAt = 'Customization::AttachedFile-attachedAt',
  Customization_AttachedFile_modifiedAt = 'Customization::AttachedFile-modifiedAt',
  InvocationAction_argument = "InvocationAction-argument",
  Action_localPostcondition = "Action-localPostcondition",
  Action_localPrecondition = "Action-localPrecondition",
  DirectedRelationship_target = "DirectedRelationship-target",
  InformationFlow_conveyed = "InformationFlow-conveyed",
  ConnectorEnd_role = "ConnectorEnd-role",
  DiagramMap_direction="DiagramMap-direction",
  Slot_value = "Slot-value",
  InstanceTableSlot_value = "InstanceTableSlot-value",

  MultiplicityElement_multiplicity = "MultiplicityElement-multiplicity",
  Class_nestedClassifier = "Class-nestedClassifier", // 嵌套分类器
  ActiveImage_ActiveElement = "ActiveImage-ActiveElement",
  ActiveImage_OnClick = "ActiveImage-OnClick",
  ImageSwitcher_ShowEmptyImageForUnspecifiedValue = "ImageSwitcher-ShowEmptyImageForUnspecifiedValue",
  Class_ownedOperation = "Class-ownedOperation",
  Class_ownedReception = "Class-ownedReception",
  Property_qualifier = "Property-qualifier",
  SysML_FlowProperty_direction = "SysML.FlowProperty.direction",
  SysML_FlowPort_direction = "SysML.FlowPort.direction",

  Element_owner = "Element-owner",
  Class_ownedAttribute = "Class-ownedAttribute", // 拥有属性
  BehavioredClassifier_ownedBehavior = "BehavioredClassifier-ownedBehavior",
  Classifier_collaborationUse = "Classifier-collaborationUse",
  Classifier_ownedUseCase = "Classifier-ownedUseCase",
  Property_redefinedProperty = "Property-redefinedProperty",
  Connector_end = "Connector-end",
  PartICDTable_part = "PartICDTable-part",
  InstanceTable_classifiers = "InstanceTable-classifiers",
  ElementPropertyPath_propertyPath = 'SysML.ElementPropertyPath.propertyPath',
  ConnectorEnd_partWithPort = 'ConnectorEnd-partWithPort',

  Element_ownedComment = "Element-ownedComment",
  Element_ownedElement = "Element-ownedElement",
  Element_constraints = "Element-constraints",
  Element_appliedStereotype = "Element-appliedStereotype",
  Element_appliedStereotypeInstance = "Element-appliedStereotypeInstance",
  Element_ownedInstanceSpecification = "Element_ownedInstanceSpecification",
  Element_packageDiagram = "Element_packageDiagram",
  Element_useCaseDiagram = "Element_useCaseDiagram",
  Element_classDiagram = "Element_classDiagram",
  Element_activityDiagram = "Element_activityDiagram",
  Element_stateMachineDiagram = "Element_stateMachineDiagram",
  Element_interactionDiagram = "Element_interactionDiagram",

  Model_viewpoint = "Model-viewpoint",
  SysML_ProxyPort_direction = "SysML.ProxyPort.direction",

  NamedElement_name = 'NamedElement-name',
  NamedElement_clientDependency = "NamedElement-clientDependency",
  NamedElement_nameExpression = "NamedElement-nameExpression",
  NamedElement_namespace = "NamedElement-namespace",
  NamedElement_qualifiedName = "NamedElement-qualifiedName",

  Namespace_elementImport = "Namespace-elementImport",
  Namespace_importedMember = "Namespace-importedMember",
  Namespace_member = "Namespace-member",
  Namespace_ownedMember = "Namespace-ownedMember",
  Namespace_ownedRule = "Namespace-ownedRule",
  Namespace_packageImport = "Namespace-packageImport",

  SysML_Block_isEncapsulated="SysML.Block.isEncapsulated",
  Pseudostate_kind = "Pseudostate-kind",
  Pseudostate_state = "Pseudostate-state",
  Pseudostate_stateMachine = "Pseudostate-stateMachine",
  PackageableElement_visibility = "PackageableElement-visibility",
  Package_URI = "Package-URI",
  Package_nestedPackage = "Package-nestedPackage",
  Package_nestingPackage = "Package-nestingPackage",
  Package_ownedStereotype = "Package-ownedStereotype",
  Package_ownedType = "Package-ownedType",
  Package_packageMerge = "Package-packageMerge",
  Package_packagedElement = "Package-packagedElement",
  Package_profileApplication = "Package-profileApplication",
  ParameterableElement_owningTemplateParameter = "ParameterableElement-owningTemplateParameter",
  ParameterableElement_templateParameter = "ParameterableElement-templateParameter",

  RedefinableElement_isLeaf = "RedefinableElement-isLeaf",
  RedefinableElement_redefinedElement = "RedefinableElement-redefinedElement",
  RedefinableElement_redefinitionContext = "RedefinableElement-redefinitionContext",

  State_redefinitionContext = "State-redefinitionContext",
  State_redefinedState = "State-redefinedState",
  State_connection = "State-connection",
  BehavioralFeature_concurrency = "BehavioralFeature-concurrency",
  State_connectionPoint = "State-connectionPoint",
  State_deferrableTrigger = "State-deferrableTrigger",
  State_doActivity = "State-doActivity",
  State_entry = "State-entry",
  Parameter_direction = 'Parameter-direction',
  State_exit = "State-exit",
  State_isComposite = "State-isComposite",
  State_isOrthogonal = "State-isOrthogonal",
  State_isSimple = "State-isSimple",
  State_isSubmachineState = "State-isSubmachineState",
  State_region = "State-region",
  State_stateInvariant = "State-stateInvariant",
  State_submachine = "State-submachine",
  StateMachine_connectionPoint = "StateMachine-connectionPoint",
  ConnectionPointReference_entry='ConnectionPointReference-entry',
  ConnectionPointReference_exit='ConnectionPointReference-exit',

  TypedElement_type = 'TypedElement-type',
  AcceptEventAction_trigger = 'AcceptEventAction-trigger',
  TemplateableElement_ownedTemplateSignature = "TemplateableElement-ownedTemplateSignature",
  TemplateableElement_templateBinding = "TemplateableElement-templateBinding",
  Transition_container = "Transition-container",
  Transition_effect = "Transition-effect",
  Transition_guard = "Transition-guard",
  Transition_kind = "Transition-kind",
  Transition_redefinedTransition = "Transition-redefinedTransition",
  Transition_redefinitionContext = "Transition-redefinitionContext",
  Transition_source = "Transition-source",
  Transition_target = "Transition-target",
  Transition_trigger = "Transition-trigger",
  Trigger_eventType = "Trigger-eventType",
  TimeEvent_when = "TimeEvent-when",

  Vertex_container = "Vertex-container",
  Vertex_incoming = "Vertex-incoming",
  Vertex_outgoing = "Vertex-outgoing",

  Reception_signal = "Reception-signal",

  CallBehaviorAction_behavior = "CallBehaviorAction-behavior",
  Property_defaultValue = "Property-defaultValue",

  UseCase_subject = "UseCase-subject",
  Diagram_context = "Diagram-context",
  AbstractRequirement_text = "SysML.AbstractRequirement.text",
  AbstractRequirement_reqId = "SysML.AbstractRequirement.id",
  ActivityEdge_guard = "ActivityEdge-guard",
  JoinNode_joinSpec = "JoinNode-joinSpec",
  Duration_expr = "Duration-expr",
  IntervalConstraint_specification = "IntervalConstraint-specification",
  LiteralBoolean_value = "LiteralBoolean-value",
  LiteralInteger_value = "LiteralInteger-value",
  LiteralReal_value = "LiteralReal-value",
  LiteralString_value = "LiteralString-value",
  LiteralUnlimitedNatural_value = "LiteralUnlimitedNatural-value",
  TimeExpression_expr = "TimeExpression-expr",
  Extend_condition = "Extend-condition",
  ProtocolTransition_postCondition = "ProtocolTransition-postCondition",
  ProtocolTransition_preCondition = "ProtocolTransition-preCondition",
  InteractionOperand_guard = "InteractionOperand-guard",
  InteractionUse_returnValue = "InteractionUse-returnValue",
  Lifeline_selector = "Lifeline-selector",
  StateInvariant_invariant = "StateInvariant-invariant",
  Abstraction_mapping = "Abstraction-mapping",
  Constraint_specification = "Constraint-specification",
  ChangeEvent_changeExpression = "ChangeEvent-changeExpression",
  InstanceSpecification_specification = "InstanceSpecification-specification",
  Operation_bodyCondition = "Operation-bodyCondition",
  WriteStructuralFeatureAction_value = "WriteStructuralFeatureAction-value",
  WriteStructuralFeatureAction_result="WriteStructuralFeatureAction-result",
  WriteVariableAction_value = "WriteVariableAction-value",
  ReadSelfAction_result="ReadSelfAction-result",
  ValuePin_value = "ValuePin-value",
  MultiplicityElement_lowerValue = "MultiplicityElement-lowerValue",
  MultiplicityElement_upperValue = "MultiplicityElement-upperValue",
  ValueSpecificationAction_value = "ValueSpecificationAction-value",

  DiagramMatrix_columnHeaderHeight = "DiagramMatrix-columnHeaderHeight",
  DiagramMatrix_rowHeaderWidth = "DiagramMatrix-rowHeaderWidth",
  DiagramMatrix_dependencyCriteria = "DiagramMatrix-dependencyCriteria",
  DiagramMap_relationCriterion = "DiagramMap-relationCriterion",
  DiagramMatrix_columnCollapsedNodes = "DiagramMatrix-columnCollapsedNodes",
  DiagramMatrix_rowCollapsedNodes = "DiagramMatrix-rowCollapsedNodes",
  DiagramMatrix_direction = "DiagramMatrix-direction",
  DiagramMatrix_rowElementType = "DiagramMatrix-rowElementType",
  DiagramMatrix_columnElementType = "DiagramMatrix-columnElementType",
  DiagramMatrix_rowScope = "DiagramMatrix-rowScope",
  DiagramMatrix_columnScope = "DiagramMatrix-columnScope",
  DiagramMatrix_removedRowElements = "DiagramMatrix-removedRowElements",
  DiagramMatrix_removedColumnElements = "DiagramMatrix-removedColumnElements",
  DiagramMatrix_context = "DiagramMatrix-context",
  DiagramMatrix_showElements = "DiagramMatrix-showElements",

  DiagramTable_rowElementType = "DiagramTable-rowElementType",
  DiagramTable_displayMode = "DiagramTable-displayMode",
  InstanceTable_showUnitOnValues = "InstanceTable-showUnitOnValues",
  InstanceTable_showUnitOnColumn = "InstanceTable-showUnitOnColumn",
  DiagramTable_scope = "DiagramTable-scope",
  Parameter_defaultValue = 'Parameter-defaultValue',
  PartICDTable_itemFlow = 'PartICDTable-item-flow',
  ItemFlow_name='ItemFlow-name',
  ItemFlow_direction='ItemFlow-direction',

  InstanceSpecification_classifier='InstanceSpecification-classifier',
  AddStructuralFeatureValueAction_insertAt="AddStructuralFeatureValueAction-insertAt",
  Behavior_context="Behavior-context",
  DurationConstraint_specification="DurationConstraint-specification",
  DurationInterval_max="DurationInterval-max",
  DurationInterval_min="DurationInterval-min",
  TimeConstraint_specification="TimeConstraint-specification",
  CombinedFragment_interactionOperator="CombinedFragment-interactionOperator",
  Customization_PropertyGroup_properties="Customization::PropertyGroup-properties",
  Customization_PropertyGroup_columns="Customization::PropertyGroup-columns",

  SimulationConfig_UI = "SimulationConfig-UI",
  SelectPropertiesConfig_represents = "SelectPropertiesConfig-represents",
  TimeSeriesChart_Title = "TimeSeriesChart-title",
  TimeSeriesChart_YLabel = "TimeSeriesChart-yLabel",
  TimeSeriesChart_refreshRate = "TimeSeriesChart-refreshRate",
  TimeSeriesChart_gridX = "TimeSeriesChart-gridX",
  TimeSeriesChart_gridY = "TimeSeriesChart-gridY",
  SelectPropertiesConfig_value = "SelectPropertiesConfig-value",
  TimeSeriesChart_LineraInterpolation = "TimeSeriesChart-lineraInterpolation",
  TimeSeriesChart_annotateFailures = "TimeSeriesChart-annotateFailures",
  TimeSeriesChart_fixedRange = "TimeSeriesChart-fixedRange",
  TimeSeriesChart_maxValue = "TimeSeriesChart-maxValue",
  TimeSeriesChart_minValue = "TimeSeriesChart-minValue",
  TimeSeriesChart_fixedTimeLength = "TimeSeriesChart-fixedTimeLength",
  TimeSeriesChart_fixedTimeLocation = "TimeSeriesChart-fixedTimeLocation",
  TimeSeriesChart_recordPlotDataAs = "TimeSeriesChart-recordPlotDataAs",
  TimeSeriesChart_resultFile = "TimeSeriesChart-resultFile",

  TimeSeriesChart_keepOpenAfterTermination = "TimeSeriesChart-keepOpenAfterTermination",

  TimeSeriesChart_plotColor = "TimeSeriesChart-plotColor",
  FrameMaximize = 'Frame-maximize',
  FrameMinimize = 'Frame-minimize',
  SimulationConfig_ClockRatio = "SimulationConfig-clockRatio",
  SimulationConfig_StartTime = "SimulationConfig-startTime",
  SimulationConfig_StepSize = "SimulationConfig-stepSize",
  SimulationConfig_ClockMode = "SimulationConfig-clockMode",
  SimulationConfig_IsRelativeTime = "SimulationConfig-isRelativeTime",

  NestedUIConfig_Config = "NestedUIConfig-config",

  /* timeline */
  TimelineChart_Dynamic = "TimelineChart-dynamic",
  TimelineChart_IgnoredElements = "TimelineChart-ignoredElements",
  TimelineChart_ContextPlot = "TimelineChart-contextPlot",
  TimelineChart_TimelineMode = "TimelineChart-timelineMode",
  TimeSeriesChart_KeepOpenAfterTermination = "TimeSeriesChart-keepOpenAfterTermination",
  TimeSeriesChart_FixedTimeLocation = "TimeSeriesChart-fixedTimeLocation",
  TimelineChart_FixedTimeLength = "TimelineChart-fixedTimeLength",
}

export enum Direction {
  LEFT = "left",
  RIGHT = "right",
  TOP = "top",
  BOTTOM = "bottom"
}

export enum ConnectStatus {
  UNCONNECT = 0,
  CONNECTED = 1,
  RECONNECTING = 2,
  CLOSED = 3,
  CONNECT_ERROR = 4
}
